package com.example.ureport2.demo.service.impl;

import com.example.ureport2.demo.mapper.DatasetMapper;
import com.example.ureport2.demo.model.Dataset;
import com.example.ureport2.demo.service.DatasetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @author zero
 * @date 2019-04-28
 **/
@Slf4j
@Service("datasetServiceImpl")
public class DatasetServiceImpl implements DatasetService {

    private final DatasetMapper mapper;

    public DatasetServiceImpl(DatasetMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public List<Dataset> loadReportData(String dsName, String datasetName, Map<String, Object> parameters) {
        log.info("dataSourceName: {} datasetName: {}", dsName, datasetName);
        log.info("parameters: {}", parameters);

        List<Dataset> all = mapper.findAll();
        return all == null ? new ArrayList<>() : all;
    }
}
